package com.youlu.campus.config;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.sms.v20210111.SmsClient;
import com.tencentcloudapi.vms.v20200902.VmsClient;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author : [dengbo]
 * @className : TencentcloudApiConfig
 * @description : [描述说明该类的功能]
 * @createTime : [2022/5/9 23:31]
 */
@Data
@Component
public class TencentcloudApiConfig {
    private final static String BIEJING_REGION = "ap-beijing";
    private final static String GUANG_ZHOU_REGION = "ap-guangzhou";
    private final static String NANJIN_REGION = "ap-nanjing";

    /**
     *  腾讯云secretId
     */
    @Value("${sys.tencentcloud.secretId}")
    private String secretId;

    /**
     *  腾讯云secretKey
     */
    @Value("${sys.tencentcloud.secretKey}")
    private String secretKey;

    /**
     *  短信SDK AppID
     */
    @Value("${sys.tencentcloud.smsAppId}")
    private String smsAppId;

    /**
     *  语音应用SDK AppID
     */
    @Value("${sys.tencentcloud.voiceAppId}")
    private String voiceAppId;

    @Bean
    public VmsClient vmsClient() {
        Credential cred = new Credential(secretId, secretKey);
        /* 非必要步骤:
         * 实例化一个客户端配置对象，可以指定超时时间等配置 */
        ClientProfile clientProfile = new ClientProfile();
        /* SDK默认用TC3-HMAC-SHA256进行签名
         * 非必要请不要修改这个字段 */
        VmsClient client = new VmsClient(cred, BIEJING_REGION, clientProfile);
        return client;
    }

    @Bean
    public SmsClient smsClient() {
        Credential cred = new Credential(secretId, secretKey);
        ClientProfile clientProfile = new ClientProfile();
        // SDK默认用TC3-HMAC-SHA256进行签名 非必要请不要修改这个字段
        SmsClient client = new SmsClient(cred, BIEJING_REGION, clientProfile);
        return client;
    }
}
